/**
* ...
* @author Default
* @version 0.1
*/

package kizzo.utils 
{	
	import flash.events.Event;

	public class CustomEvent extends Event
	{
		public var object:Object;		
		
		function CustomEvent(type:String, object:Object)
		{
			super(type);
			if (object == null) 
				throw new Error("CustomEvent with null object");
			this.object = object;			
		}
		
		public function compare(event:CustomEvent):Boolean
		{
			var same:Boolean = true;			
			
			if (this.type == event.type && this.object != null && event.object != null)
			{
				for (var prop:String in this.object)
				{
					if (!event.object.hasOwnProperty(prop))
						same = false;
					else if	(this.object[prop] != event.object[prop])
						same = false;
				}
				
				for (prop in event.object)
				{
					if (!this.object.hasOwnProperty(prop))
						same = false;
				}
			}
			else if (this.object == null && event.object == null)
			{
			}
			else
				same = false;
			
			return same;
		}
		
		override public function toString():String
		{
			return super.toString() + this.object.toString();
		}
	}
	
}
